﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ModbusCommunicate
{
    public    class ModbusMsg
    {
        /// <summary>
        /// <para>目标gprs编号</para>
        /// <para>发送数据时，gprs编号：-1表示群发，当前组号下所有节点设备能够接收到数据</para>
        /// <para>接收数据时，收到的GPRS编号</para>
        /// </summary>
        public string socket_id { get; set; }

        /// <summary>
        /// 设备编号
        /// </summary>
        public int device_id { get; set; }

        /// <summary>
        /// 设备功能码
        /// </summary>
        public int device_cmd { get; set; }

        /// <summary>
        /// 是否低位在前
        /// 默认高位在前
        /// </summary>
        public bool IsLowBitFirst { get; set; }
    }


    /// <summary>
    /// modbus读取数据
    /// </summary>
    public class ModbusSend : ModbusMsg
    {
        /// <summary>
        /// 开始读取(写入)的寄存器
        /// </summary>
        public int device_startreg { get; set; }

        /// <summary>
        /// <para>读取寄存器个数</para>
        /// <para>读寄存器时写入寄存器数组等于Null</para>
        /// </summary>
        public int device_reglength { get; set; }

        /// <summary>
        /// <para>写入寄存器的数组</para>
        /// <para>写入寄存器数组时，读取寄存器个数等于0</para>
        /// </summary>
        public byte[] device_WriteData { get; set; }

        /// <summary>
        /// 无线模块ID,0代表透传
        /// </summary>
        public int wireless_id { get; set; }

    }
    /// <summary>
    /// modbus数据注册类
    /// </summary>
    public class ModbusReg
    {
        /// <summary>
        /// 注册编号
        /// </summary>
        public string reg_id { get; set; }

        /// <summary>
        /// 注册手机号
        /// </summary>
        public string phone { get; set; }

        /// <summary>
        /// 设备类型
        /// </summary>
        public int devicetype { get; set; }

        /// <summary>
        /// 验证字符串
        /// </summary>
        public string user_key { get; set; }
    }
}
